iT邦幫忙

17

Day 7: 清單,學習如何儲存多個資料

c#
  • 分享至 

  • xImage
  •  

什麼是清單?
是一種可以儲存多筆資料的資料結構,動態大小,可以隨時新增、刪除資料

  • 資料可以是相同型態(例如全是整數),也可以是 不同型態(例如字串、數字、布林混合)
  • 資料有順序性(Ordered),存放的順序會被保留下來
  • 清單是可變的(Mutable),可以新增、刪除、修改元素
  1. 清單的建立方式
    清單需要 System.Collections.Generic 命名空間
    https://ithelp.ithome.com.tw/upload/images/20250922/201789251ojFxwxeu2.png

  2. 新增元素
    https://ithelp.ithome.com.tw/upload/images/20250922/20178925sQraD9J9d9.png

  3. 存取與修改元素
    https://ithelp.ithome.com.tw/upload/images/20250922/20178925zaqTgC3sCa.png

  4. 刪除元素
    https://ithelp.ithome.com.tw/upload/images/20250922/20178925JqnBeIdeiR.png

  5. 迴圈遍歷清單
    https://ithelp.ithome.com.tw/upload/images/20250922/20178925A14dJ8OrFl.png

  6. 二維清單(巢狀 List)
    https://ithelp.ithome.com.tw/upload/images/20250922/20178925zoPtWgH18m.png

範例
https://ithelp.ithome.com.tw/upload/images/20250922/20178925GNWCw5C1zY.png


圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言